package cn.wen.yinxiu.product.dao;

import cn.wen.yinxiu.product.entity.StockSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

/**
 *
 * @ClassName: StockSkuDao
 * @Author 小飞
 * @Email coderwen22@163.com
 * @Date 2023-05-22 09:55:17
 * @Description: 商品库存的Dao层
 */
@Mapper
@Component
public interface StockSkuDao extends BaseMapper<StockSkuEntity> {

    /**
     * 获取商品的库存数
     *
     * @param skuId
     * @return
     */
    Long getSkuStock(@Param("skuId") Long skuId);

    /**
     * 锁库存
     *
     * @param skuId
     * @param count
     * @return
     */
    Long lockSkuStock(@Param("skuId") Long skuId, @Param("count") Integer count);

    /**
     * 解锁库存
     *
     * @param skuId
     * @param num
     */
    void unLockStock(@Param("skuId") Long skuId, @Param("num") Integer num);
}
